package model;

import lejos.nxt.*;

public class LineFollower {
	private int currentValue;
	private static ColorLightSensor sensor;
	private int offset;
	
	public LineFollower () {
		sensor=new ColorLightSensor(SensorPort.S1, ColorLightSensor.TYPE_COLORBLUE);
		//sensor.setFloodlight(Color.BLUE);
	}

	public void calibrate() {
		System.out.println("Stand on black, then press enter");
		Button.waitForPress();
		getSensor().calibrateHigh();
		
		System.out.println("Stand on white, then press enter");
		Button.waitForPress();
		getSensor().calibrateLow();
	}
	
	public boolean isOnSameColorAsCurrent () {
		return this.getColor()==this.getCurrentColor();
	}
	public int getCurrentColor() {
		return currentValue;
	}
	public void updateCurrentColor() {
		currentValue=getColor();
	}
	public int getColor() {
		return sensor.readValue();
	}
	public ColorLightSensor getSensor(){
		return sensor;
	}	
}
